import 'package:ai_model/app/core/network/core/api_client.dart';
import 'package:ai_model/app/core/network/core/net_data.dart';
import 'package:ai_model/app/core/network/data/api_do_login_by_s_m_s_captcha_entity.dart';
import 'package:ai_model/app/core/network/data/basic_entity.dart';
import 'package:dio/dio.dart' hide FormData;
import 'package:dio/dio.dart' as dio show FormData;

/// 认证相关API扩展
extension AuthApiExtension on ApiClient {
  /// 1. 获取登录验证码
  Future<NetData<BasicEntity?>> sendLoginSMSCaptcha(String phoneNumber) async {
    var data = {"phoneNumber": phoneNumber};
    return request<BasicEntity>('app/sendLoginSMSCaptcha',
        data: dio.FormData.fromMap(data));
  }

  /// 2. 使用验证码登录
  Future<NetData<ApiDoLoginBySMSCaptchaEntity?>> doLoginBySMSCaptcha(
      String phoneNumber, String smsCaptcha) async {
    var data = {"phoneNumber": phoneNumber, "smsCaptcha": smsCaptcha};
    return request<ApiDoLoginBySMSCaptchaEntity>('app/doLoginBySMSCaptcha',
        data: dio.FormData.fromMap(data));
  }
}
